package vn.edu.saigontech.ncms.web.student;

import vn.edu.saigontech.ncms.util.Checker;
import vn.edu.saigontech.ncms.web.AbstractValidator;

@SuppressWarnings("serial")
public class ValidateMoveUpTestAction extends AbstractValidator {
	private Long id;
	private String date;
	private String receiptNo;
	private String listeningScore;
	private String writtenScore;
	private String speakingScore;
	private String grammarScore;
	private String readingScore;
	private String fee;
	
	private boolean editAll = false;

	@Override
	public String check() {
		if(!this.editAll) {
			this.check0(this.id, this.date, this.writtenScore, this.speakingScore, this.listeningScore, this.grammarScore, this.readingScore, this.receiptNo, this.fee);
		}
		return this.toSuccess();
	}
	
	private void check0(Long _id, String _date, String _writtenScore, String _speakingScore, String _listeningScore, String _grammarScore, String _readingScore, String _receiptNo, String _fee) {
		if(Checker.isEmpty(_date)) {
			this.sendKeyError("validator.required", "date");
		}
		if(!Checker.isDate(_date, this.i18n("format.date"))) {
			this.sendKeyError("validator.mask", "date", "format.date");
		}
		if(Checker.isEmpty(_listeningScore)) {
			_listeningScore = "0";
		}
		if(!Checker.isDouble(_listeningScore) || !Checker.isInRange(Double.valueOf(_listeningScore), 0, 100)) {
			this.sendKeyError("validator.invalid", "listeningScore");
		}
		if(Checker.isEmpty(_speakingScore)) {
			_speakingScore = "0";
		}
		if(!Checker.isDouble(_speakingScore) || !Checker.isInRange(Double.valueOf(_speakingScore), 0, 100)) {
			this.sendKeyError("validator.invalid", "speakingScore");
		}
		if(Checker.isEmpty(_grammarScore)) {
			_grammarScore = "0";
		}
		if(!Checker.isDouble(_grammarScore) || !Checker.isInRange(Double.valueOf(_grammarScore), 0, 100)) {
			this.sendKeyError("validator.invalid", "grammarScore");
		}
		if(Checker.isEmpty(_readingScore)) {
			_readingScore = "0";
		}
		if(!Checker.isDouble(_readingScore) || !Checker.isInRange(Double.valueOf(_readingScore), 0, 100)) {
			this.sendKeyError("validator.invalid", "readingScore");
		}
		if(Checker.isEmpty(_writtenScore)) {
			_writtenScore = "0";
		}
		if(!Checker.isDouble(_writtenScore) || !Checker.isInRange(Double.valueOf(_writtenScore), 0, 100)) {
			this.sendKeyError("validator.invalid", "writtenScore");
		}
		
		if(!Checker.isEmpty(_fee)) {
			if(!Checker.isDouble(_fee)) {
				this.sendKeyError("validator.invalid", "fee");
			}
		}
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getReceiptNo() {
		return receiptNo;
	}

	public void setReceiptNo(String receiptNo) {
		this.receiptNo = receiptNo;
	}

	public String getListeningScore() {
		return listeningScore;
	}

	public void setListeningScore(String listeningScore) {
		this.listeningScore = listeningScore;
	}

	public String getWrittenScore() {
		return writtenScore;
	}

	public void setWrittenScore(String writtenScore) {
		this.writtenScore = writtenScore;
	}

	public String getSpeakingScore() {
		return speakingScore;
	}

	public void setSpeakingScore(String speakingScore) {
		this.speakingScore = speakingScore;
	}

	public String getGrammarScore() {
		return grammarScore;
	}

	public void setGrammarScore(String grammarScore) {
		this.grammarScore = grammarScore;
	}

	public String getReadingScore() {
		return readingScore;
	}

	public void setReadingScore(String readingScore) {
		this.readingScore = readingScore;
	}

	public String getFee() {
		return fee;
	}

	public void setFee(String fee) {
		this.fee = fee;
	}

	public boolean isEditAll() {
		return editAll;
	}

	public void setEditAll(boolean editAll) {
		this.editAll = editAll;
	}
	
	
}
